Skip to content

feat: accept a precompiled check in the worker's getOptions - #261

Open
alexander-akait wants to merge 4 commits into
mainfrom
feat/getoptions-precompiled-check
Open

alexander-akait wants to merge 4 commits into
mainfrom
feat/getoptions-precompiled-check

Conversation

@alexander-akait

@alexander-akait alexander-akait commented Oct 18, 2026 •

Copy link
Copy Markdown
Member

Summary

webpack/webpack#22745 adds an optional second argument to this.getOptions: this.getOptions(schema, check). When the precompiled check passes, webpack skips the schema, so schema-utils and ajv aren't loaded. Loaders are starting to pass it (webpack/coffee-loader#240, webpack/postcss-loader#746).

The worker reimplements getOptions, so a loader running under thread-loader would still compile its schema in every worker. The worker's getOptions now takes the same second argument:

  • A passing check returns the options without running the schema.
  • A failing check, or no check, validates as before, with the same error messages.

Tests

test/options-check.test.js runs a loader through a real worker:

  • When the check passes, options that the schema would reject come back without an error. This test fails without the change in src/worker.js.
  • When the check fails, the full validation error is reported.

npm run lint and the full suite (17 tests, 6 snapshots) pass locally.


Generated by Claude Code

Summary by CodeRabbit

  • New Features
    • Loader options can now be approved by an optional precompiled check, avoiding schema validation when the check passes. If it does not pass, the existing schema validation remains in place.
  • Bug Fixes
    • Improved validation feedback when a precompiled check rejects options that the schema accepts, including a deprecation warning.

webpack's getOptions(schema, check) skips the schema when the check
passes (webpack/webpack#22745). The worker reimplements getOptions, so
a loader running under thread-loader kept compiling its schema. It now
takes the same second argument; a failing check still validates fully.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QYPkbvwyRWt2SHgXDoYRdo
@coderabbitai

coderabbitai Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The loader-context getOptions method now accepts a schema, optional configuration, and precompiled checks. A passing check returns options without schema validation. Otherwise, the method resolves and validates the schema, using its title for default validation metadata when available. If a check rejects options that the schema accepts, the method emits a deprecation warning. New webpack tests cover these paths through thread-loader.

Merge Risk: Minimal · up to 8902c

This change lets loaders pass a precompiled options check so workers can skip schema compilation when the check passes. Failing or absent checks still validate as before. No actionable merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "feat: accept a precompiled check in the worker's getOptions" matches the main change. The worker's getOptions now accepts an optional precompiled check, and a passing check skips schema com…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "feat: accept a precompiled check in the worker's getOptions" matches the main change. The worker's getOptions now accepts an optional precompiled check, and a passing check skips schema compilation and validation. The title is short, specific, and follows the conventional commit prefix. It does not mention the deprecation warning or the schema-utils loading change, which is expected for a title.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 9bbffc8f-fe10-4963-96b4-84051b372618
Commits

Reviewing files that changed from the base of the PR and between d537f4e and 8902c99.

Files ignored due to path filters: 1

  • package-lock.json is excluded by !**/package-lock.json
Files selected for processing: 3

  • src/worker.js
  • test/options-check.test.js
  • test/options-check/options-check-loader.js

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

@codecov

codecov Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 21 lines in your changes missing coverage. Please review.
✅ Project coverage is 14.45%. Comparing base (95079c4) to head (8902c99).

Files with missing lines Patch % Lines
src/worker.js 0.00% 15 Missing and 6 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #261      +/-   ##
==========================================
- Coverage   14.75%   14.45%   -0.30%     
==========================================
  Files           9        9              
  Lines         732      747      +15     
  Branches      166      180      +14     
==========================================
  Hits          108      108              
- Misses        543      553      +10     
- Partials       81       86       +5     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

fast-uri <= 3.1.7 has high severity advisories (GHSA-v2hh-gcrm-f6hx and
others), which fail `npm audit --omit=dev` in the lint job. 3.1.8 is
within ajv's ^3.0.1 range, so only the lockfile changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QYPkbvwyRWt2SHgXDoYRdo

Copy link
Copy Markdown
Member Author

codecov/patch reports 0% because src/worker.js runs in a separate worker process, and Jest only collects coverage in its own process. test/options-check.test.js exercises both new branches through a real worker (the first test fails without this change). Project coverage is unchanged at 14.75%.

The lint job's npm audit --omit=dev failure came from fast-uri 3.0.1 and fails on main too. #262 bumps it to 3.1.8, and the same commit is included here.


Generated by Claude Code

Take the check last or in the configuration's place, accept a function
returning the schema, name the errors by the configuration, then the
schema title, then "Loader", warn when the check rejects options the
schema accepts, and load schema-utils only when validating.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant